package com.robot.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.robot.dao.dto.UserLoginDTO;
import com.robot.dao.entity.User;
import com.robot.dao.vo.UserInfoVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user where id=#{id} and user_phone = #{userPhone} and company_code=#{companyCode} and is_delete=1")
    User selectByPhoneAndCompany(User user);

    @Select("select * from user where user_name = #{userName}")
    User query(User user);

    @Select("select * from user where id = #{id}")
    User queryById(User user);

//    @Insert("insert into user (user_name,user_type) values (#{userName},#{userType})")
    void create(User user);

    UserInfoVO searchByPhone(String userPhone);

    UserInfoVO searchByPhoneAndPassWord(UserLoginDTO userLoginDTO);

    List<User> selectUserList(User user);

    @Select("SELECT id FROM user WHERE company_code = #{companyCode}")
    List<String> findUsersByCompanyCode(@Param("companyCode") String companyCode);
}
